package com.sskj.gocoin.mine;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.HttpData;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.mine.data.FeedBackType;
import com.sskj.gocoin.p.base.BasePresenter;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/04/02
 */
class FeedBackPresenter extends BasePresenter<FeedBackActivity> {
    public void  feedBack(int typeId,String content,String tel){
        OkGo.<HttpData<Object>> post(HttpConfig.BASE_URL+HttpConfig.FEEDBACK)
                .params("type_id",typeId)  //问题类型id
                .params("desc",content) //问题描述
                .params("user_tel",tel)  //联系方式
                .execute(new JsonCallBack<HttpData<Object>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<Object>> response) {
                        if (response.body().getCode()==200){
                           mView.submitSuccess();
                        }
                    }
                });
    }

    public void  feedBackType(){
        OkGo.<HttpData<List<FeedBackType>>> get(HttpConfig.BASE_URL+HttpConfig.FEEDBACKTYPE)
                .execute(new JsonCallBack<HttpData<List<FeedBackType>>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<List<FeedBackType>>> response) {
                        if (response.body().getCode()==200){
                            mView.onDataSuccess(response.body().getData());
                        }
                    }
                });
    }
}
